<template>
  <div id="dp_header">
    <div class="header-common-bar header">
      <div class="header-common-bar-zone">
        <div class="header-common-bar-area header-app-logo">
          <router-link to="/"><img :src="log_url" alt="" class="logo-style" /><span>后台管理系统</span></router-link>
        </div>
        <router-link to="/">
          <div class="header-common-bar-area">
            <i data-v-aecee3a6="" class="icon-headerapp icon-cloud-homepage"></i>
            <span>首页</span>
          </div>
        </router-link>
        <router-link to="/">
          <div class="header-common-bar-area">
            <i data-v-aecee3a6="" class="icon-headerapp icon-first-workbench"></i>
            <span>工作台</span>
          </div>
        </router-link>
        <router-link to="/">
          <div class="header-common-bar-area">
            <i data-v-aecee3a6="" class="icon-headerapp icon-cloud-service"></i>
            <span>服务</span>
          </div>
        </router-link>
      </div>
      <div class="header-common-bar-zone">
        <div class="header-common-bar-area">
          <el-tooltip class="box-item" effect="dark" content="通知" placement="bottom">
            <el-icon>
              <BellFilled />
            </el-icon>
          </el-tooltip>
        </div>
        <div class="header-common-bar-area">
          <el-tooltip class="box-item" effect="dark" content="待办事宜" placement="bottom">
            <el-icon>
              <CircleCheck />
            </el-icon>
          </el-tooltip>
        </div>
        <div class="header-common-bar-area">
          <el-tooltip class="box-item" effect="dark" content="帮助信息" placement="bottom">
            <el-icon>
              <QuestionFilled />
            </el-icon>
          </el-tooltip>
        </div>
        <div class="header-common-bar-area">
          <el-dropdown>
            <el-icon class="no-outline">
              <Avatar />
            </el-icon>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人设置</el-dropdown-item>
                <el-dropdown-item divided @click="logout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
let log_url = require("@/assets/log/logo-2024.png");
import { ElMessage } from 'element-plus';
import { useRouter } from "vue-router";
import { useStore } from "vuex";

const router = useRouter();
const store = useStore();

const logout = () => {
  // 清除可能存储在 localStorage 或 sessionStorage 的用户信息
  localStorage.clear();

  ElMessage({
    message: "退出登录",
    type: "success",
  });
  // 跳转到登录页面
  router.push("/login");
};
</script>

<style lang="scss" scoped>
.header {
  box-shadow: var(--box-line-shadow);
}

.el-icon {
  color: var(--icon-base-color);
}

.header-common-bar {
  width: 100%;
  height: 40px;
  display: flex;
  justify-content: space-between;
  background-color: var(--base-global-bg);
  color: var(--base-text);

  .header-common-bar-zone {
    display: flex;
    justify-content: center;
    align-content: center;
    padding: 8px;
    gap: 8px;

    .header-common-bar-area {
      display: flex;
      padding: 0px 15px;
      cursor: pointer;

      span {
        height: 24px;
        line-height: 24px;
      }
    }
  }

  .header-app-logo {
    height: 28px;
    display: flex;
    padding: 0 !important;
    justify-content: center;
    align-items: center;

    .logo-style {
      width: 28px;
      height: 28px;
      vertical-align: middle;
    }

    >a {
      display: flex;
      justify-content: center;      
      color: var(--base-logo-text);

      span{
        font-weight: 700;
        height: 28px;
        line-height: 28px;
        margin-left: 8px;
      }

      &:hover{
        color: var(--base-logo-text);
      }
    }
  }

  a {
    color: var(--base-text);
  }

  a:hover {
    color: var(--brand-hover);
  }
}

/* 移除 图标多余的外框样式 */
.no-outline:focus,
.no-outline:active {
  outline: none !important;
}
</style>